import request from "../utils/common_request";

// 万维易源
const BASE_URL_WWYY= "https://route.showapi.com";
const APPKEYWWYY = "d4dfa52484534c0b8658fdde8a061f65";
const APPIDWWYY = "1532625";


// 查询快递
export function expressQueryDetail(expressOrderNumber, expressCompany, phone) {
	return request(BASE_URL_WWYY+"/2650-3",{
		showapi_appid: APPIDWWYY,
		showapi_sign: APPKEYWWYY,
		com: expressCompany,
		nu: expressOrderNumber,
		phone: phone
	},{
		method: "GET"
	})
}

// 单号查询快递公司
export function expressCompanyQueryByOrderNum(expressOrderNumber) {
	return request(BASE_URL_WWYY+"/2650-6",{
		showapi_appid: APPIDWWYY,
		showapi_sign: APPKEYWWYY,
		nu: expressOrderNumber
	},{
		method: "GET"
	})
}

// 查询快递公司列表
export function expressListQuery(expressCompany = undefined) {
	const query = {
		showapi_appid: APPIDWWYY,
		showapi_sign: APPKEYWWYY,
	}
	if (expressCompany) {
		query.exp_name = expressCompany
	}
	return request(BASE_URL_WWYY+"/2650-5", query, {
		method: "GET"
	})
}

// 单号查询价格
export function expressCompanyPriceQuery(origin_address, dest_address, weight, time) {
	return request(BASE_URL_WWYY+"/1934-4",{
		showapi_appid: APPIDWWYY,
		showapi_sign: APPKEYWWYY,
		origin_address,
		dest_address,
		weight,
		time
	},{
		method: "GET"
	})
}

// 查询快递网点
export function expressCompanyListQueryByPosition(address, com, page = 1) {
	return request(BASE_URL_WWYY+"/1841-2",{
		showapi_appid: APPIDWWYY,
		showapi_sign: APPKEYWWYY,
		address,
		com,
		page
	},{
		method: "GET"
	})
}